package com.zzedu.enmuns;

import java.util.Arrays;

/**
 * 学员类型
 */
public enum StuTypeEnum {


    FORMAL(1, "正式"),
    EXPERIENCE(2, "体验"),

    ABANDONMENT(-99, "废除"),
    ;
    final int code;

    final String desc;

    StuTypeEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static StuTypeEnum getCode(Integer code) {
        if(code==null){
            return null;
        }
        return Arrays.stream(StuTypeEnum.values()).filter(e -> e.getCode() == code).findFirst().orElse(null);
    }

    @Override
    public String toString() {
        return String.valueOf(code); // 或者 name(), 或者 desc
    }
}
